﻿using System.Linq;
using System.Web.Mvc;
using SportMeetingPlanner.Models;

namespace SportMeetingPlanner.Controllers
{
    public class HomeController : Controller
    {
        SportMeetingEntities storeDB = new SportMeetingEntities();
        //
        // GET: /Home/
        public ActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                User user = storeDB.Users.Find(User.Identity.Name);
                if (user != null)
                {
                    ViewBag.IsAdmin = user.IsAdmin;
                }
                else
                {
                    ViewBag.IsAdmin = false;
                }
            }
            else
            {
                ViewBag.IsAdmin = false;
            }

            var sports = storeDB.Sports.OrderBy(s => s.Name).ToList();
            return View(sports);
        }

    }
}
